package com.xbongbong.paas.service.field;

import com.xbongbong.paas.constant.PaasConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 吴峰
 * @date 2022/04/01 15:51
 */
@Configuration
public class FieldConfig {


    @Autowired
    private Map<String, FieldAnalysisHandler> fieldAnalysisHandlerMap;


    @Bean("fieldAnalysisHandlerMap")
    public Map<Integer, FieldAnalysisHandler> initFieldAnalysisHandlerMap() {
        Map<Integer, FieldAnalysisHandler> resultMap = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        this.fieldAnalysisHandlerMap.forEach((key, item)->{
            item.fieldType().forEach(filedType->{
                resultMap.put(filedType, item);
            });
        });
        return resultMap;
    }
}
